package com.rent.writeoff.controller;

import com.rent.writeoff.service.BatchWriteOffService;
import com.rent.writeoff.vo.WriteOffResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/write-off")
@Api(tags = "租金核销管理")
public class WriteOffController {

    @Autowired
    private BatchWriteOffService batchWriteOffService;

    @PostMapping("/batch")
    @ApiOperation(value = "触发批量核销", notes = "多线程处理所有待核销记录，返回核销汇总结果")
    public ResponseEntity<WriteOffResultVO> batchWriteOff() {
        WriteOffResultVO result = batchWriteOffService.executeBatchWriteOff();
        return ResponseEntity.ok(result);
    }
}
